package com.chenwut.test1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int n = scanner.nextInt();
            if (n < 0) {
                return;
            }
            int leftPrime = 0, rightPrime = 0;
            for (int i = n - 1; i >= 1; i--) {
                if (isPrime(i)) {
                    leftPrime = i;
                    break;
                }
            }
            for (int i = n + 1; i <= 100000000; i++) {
                if (isPrime(i)) {
                    rightPrime = i;
                    break;
                }
            }

            if (leftPrime <= 0) {
                System.out.println("0" + "" + n + "" + rightPrime);
            } else
                System.out.println(leftPrime + "" + n + "" + rightPrime);
        }
    }


    public static boolean isPrime(int n) {
        if (n <2) {
            return false;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}